package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.Warehouse;
import service.WarehouseManager;
import service.factory.ManagerFactory;

/**
 * Servlet implementation class AddCargoServlet
 */
@WebServlet(urlPatterns="/cargo/add")
public class AddCargoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   private WarehouseManager warehouseManager;
    public AddCargoServlet() {
        super();
      warehouseManager = ManagerFactory.getWarehouseManagerInstance();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Warehouse> warehouses = warehouseManager.getAllWarehouses();
		request.setAttribute("warehouse", warehouses);
		request.getRequestDispatcher("addCargo.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
